﻿Imports System.Text
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports System.Windows.Markup
Imports System.Windows
Imports System.Windows.Controls

<TestClass()> Public Class FeatureFlagTests
    Inherits TestBase

    <TestMethod()> Public Sub UIElementIsVisibleWhenFeatureIsEnabled()
        Initialize()
        Features.Register(Of FakeFeature)(New FakeFeature() With {.IsEnabled = True})
        Dim featureFlag As New FeatureFlag()
        featureFlag.Feature = GetType(FakeFeature)
        featureFlag.IsEnabled = True
        Dim mockServiceProvider = New MockServiceProvider(New MockProvideValueTarget(New Button(), Nothing))
        Assert.AreEqual(featureFlag.ProvideValue(mockServiceProvider), Visibility.Visible)

    End Sub

    <TestMethod()> Public Sub UIElementIsNotVisibleWhenFeatureIsDisabled()
        Initialize()
        Features.Register(Of FakeFeature)(New FakeFeature() With {.IsEnabled = False})
        Dim featureFlag As New FeatureFlag()
        featureFlag.Feature = GetType(FakeFeature)
        featureFlag.IsEnabled = True
        Dim mockServiceProvider = New MockServiceProvider(New MockProvideValueTarget(New Button(), Nothing))
        Assert.AreEqual(featureFlag.ProvideValue(mockServiceProvider), Visibility.Collapsed)
    End Sub

    <TestMethod()> Public Sub UIElementIsNotVisibleWhenFeatureIsEnabledAndNotEnabledExpected()
        Initialize()
        Features.Register(Of FakeFeature)(New FakeFeature() With {.IsEnabled = True})
        Dim featureFlag As New FeatureFlag()
        featureFlag.Feature = GetType(FakeFeature)
        featureFlag.IsEnabled = False
        Dim mockServiceProvider = New MockServiceProvider(New MockProvideValueTarget(New Button(), Nothing))
        Assert.AreEqual(featureFlag.ProvideValue(mockServiceProvider), Visibility.Collapsed)
    End Sub

    <TestMethod()> Public Sub UIElementIsVisibleWhenFeatureIsDisabledAndNotEnabledExpected()
        Initialize()
        Features.Register(Of FakeFeature)(New FakeFeature() With {.IsEnabled = False})
        Dim featureFlag As New FeatureFlag()
        featureFlag.Feature = GetType(FakeFeature)
        featureFlag.IsEnabled = False
        Dim mockServiceProvider = New MockServiceProvider(New MockProvideValueTarget(New Button(), Nothing))
        Assert.AreEqual(featureFlag.ProvideValue(mockServiceProvider), Visibility.Visible)
    End Sub


End Class